package com.whcoding.test.example.generic;

import com.alibaba.fastjson.JSONObject;
import com.whcoding.test.pojo.OrmDeptVO;

/**
 *
 * https://segmentfault.com/a/1190000039835272
 *
 * 泛型类
 * @param <T>
 */
public class GenericClass<T> {
    //成员变量
    private T t;

    public void function(T t) {

    }

    public T functionTwo(T t) {
        //注意，这个不是泛型方法！！！
        return t;
    }

    public static void main(String[] args) {
        GenericClass<OrmDeptVO> deptVO=new GenericClass<>();
        OrmDeptVO deptVO1=new OrmDeptVO();
        deptVO1.setDeptId(1001);
        deptVO1.setDeptName("开发");
        OrmDeptVO deptVO2= deptVO.functionTwo(deptVO1);
        System.out.println("deptVO1JSON结果为:"+JSONObject.toJSON(deptVO1));
        System.out.println("deptVO2JSON结果为:"+JSONObject.toJSON(deptVO2));
    }
}


